<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:PresentationOptions="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  mc:Ignorable="PresentationOptions"
  xmlns:local="clr-namespace:OpenWPFChart.Helpers.ChooseColorDialog">

	<DrawingBrush x:Key="checkboardBrush" 
        Stretch="None" TileMode="Tile" AlignmentX="Left" AlignmentY="Top" 
        Viewport="0,0,10,10" ViewportUnits="Absolute">
		<DrawingBrush.Drawing>
			<DrawingGroup>
				<GeometryDrawing Brush="sc# 1,1,1">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0,0,10,10" />
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
				<GeometryDrawing Brush="sc# 0.5,0.5,0.5">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="0,0,5,5" />
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
				<GeometryDrawing Brush="sc# 0.5,0.5,0.5">
					<GeometryDrawing.Geometry>
						<RectangleGeometry Rect="5,5,5,5" />
					</GeometryDrawing.Geometry>
				</GeometryDrawing>
			</DrawingGroup>
		</DrawingBrush.Drawing>
	</DrawingBrush>
	
	<!--Slider RepeatButton Style-->
	<Style x:Key="OpacitySliderRepeatButtonStyle" TargetType="{x:Type RepeatButton}">
		<Setter Property="OverridesDefaultStyle" Value="true"/>
		<Setter Property="IsTabStop" Value="false"/>
		<Setter Property="Focusable" Value="false"/>
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type RepeatButton}">
					<Border Background="{TemplateBinding Background}"/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Horizontal Thumb Style -->
	<Style x:Key="horizontalThumb" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Grid>
						<Grid.RowDefinitions>
							<RowDefinition Height="10" />
							<RowDefinition Height="*" />
							<RowDefinition Height="10" />
						</Grid.RowDefinitions>
						<Image Grid.Row="0" Width="10">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<GeometryDrawing Geometry="M 30 50 L 50 0 10 0 Z">
											<GeometryDrawing.Pen>
												<Pen Brush="Black" Thickness="25" LineJoin="Miter" />
											</GeometryDrawing.Pen>
										</GeometryDrawing>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
						<Image Grid.Row="2" Width="10">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<GeometryDrawing Geometry="M 25 0 L 10 40 40 40 Z">
											<GeometryDrawing.Pen>
												<Pen Brush="Black" Thickness="25" LineJoin="Miter" />
											</GeometryDrawing.Pen>
										</GeometryDrawing>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Horizontal Slider Template -->
	<ControlTemplate x:Key="horizontalSlider" TargetType="{x:Type local:OpacitySlider}">
		<Border Background="{TemplateBinding Background}"
			BorderBrush="{TemplateBinding BorderBrush}"
			BorderThickness="{TemplateBinding BorderThickness}">
			<Grid>
				<!--The area where the Opacity gradient is diaplayed-->
				<Border Height="{TemplateBinding Slider.Height}" MinHeight="21"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
					Background="{TemplateBinding Background}">
					<Grid Margin="5,5,5,5">
						<Border Background="{StaticResource checkboardBrush}"/>
						<Border Name="opacityGradientHost">
							<Border.Background>
								<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
									<GradientStop Offset="0.0" Color="Black" />
									<GradientStop Offset="1.0" Color="Transparent" />
								</LinearGradientBrush>
							</Border.Background>
						</Border>
					</Grid>
				</Border>

				<Track Name="PART_Track">
					<Track.DecreaseRepeatButton>
						<RepeatButton Command="Slider.DecreaseLarge"
								  Style="{StaticResource OpacitySliderRepeatButtonStyle}"/>
					</Track.DecreaseRepeatButton>

					<Track.IncreaseRepeatButton>
						<RepeatButton Command="Slider.IncreaseLarge"
								  Style="{StaticResource OpacitySliderRepeatButtonStyle}"/>
					</Track.IncreaseRepeatButton>

					<Track.Thumb>
						<Thumb Style="{StaticResource horizontalThumb}"	/>
					</Track.Thumb>
				</Track>
			</Grid>
		</Border>

		<ControlTemplate.Triggers>
			<Trigger Property="Width" Value="Auto">
				<Setter Property="MinWidth" Value="104"/>
			</Trigger>
			<Trigger Property="Height" Value="Auto">
				<Setter Property="MinHeight" Value="21"/>
			</Trigger>
			<Trigger Property="IsDirectionReversed" Value="True">
				<Setter TargetName="opacityGradientHost" Property="Background">
					<Setter.Value>
						<LinearGradientBrush StartPoint="1,0" EndPoint="0,0">
							<GradientStop Offset="0.0" Color="Black" />
							<GradientStop Offset="1.0" Color="Transparent" />
						</LinearGradientBrush>
					</Setter.Value>
				</Setter>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<!-- Vertical Thumb Style -->
	<Style x:Key="verticalThumb" TargetType="{x:Type Thumb}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Grid>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="10" />
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="10" />
						</Grid.ColumnDefinitions>
						<Image Grid.Column="0" Width="10">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<GeometryDrawing Geometry="M 0 0 L 0 20 20 10 Z">
											<GeometryDrawing.Pen>
												<Pen Brush="Black" Thickness="25" LineJoin="Miter" />
											</GeometryDrawing.Pen>
										</GeometryDrawing>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
						<Image Grid.Column="2" Width="10">
							<Image.Source>
								<DrawingImage>
									<DrawingImage.Drawing>
										<GeometryDrawing Geometry="M 20 0 L 20 20 0 10 Z">
											<GeometryDrawing.Pen>
												<Pen Brush="Black" Thickness="25" LineJoin="Miter" />
											</GeometryDrawing.Pen>
										</GeometryDrawing>
									</DrawingImage.Drawing>
								</DrawingImage>
							</Image.Source>
						</Image>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<!-- Vertical Slider Template -->
	<ControlTemplate x:Key="verticalSlider" TargetType="{x:Type local:OpacitySlider}">
		<Border Background="{TemplateBinding Background}"
			BorderBrush="{TemplateBinding BorderBrush}"
			BorderThickness="{TemplateBinding BorderThickness}">
			<Grid>
				<!--The area where the Opacity gradient is diaplayed-->
				<Border Height="{TemplateBinding Slider.Height}" MinWidth="21"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    BorderThickness="{TemplateBinding BorderThickness}"
					Background="{TemplateBinding Background}">
					<Grid Margin="5,5,5,5">
						<Border Background="{StaticResource checkboardBrush}"/>
						<Border Name="opacityGradientHost">
							<Border.Background>
								<LinearGradientBrush StartPoint="0,1" EndPoint="0,0">
									<GradientStop Offset="0.0" Color="Black" />
									<GradientStop Offset="1.0" Color="Transparent" />
								</LinearGradientBrush>
							</Border.Background>
						</Border>
					</Grid>
				</Border>

				<Track Name="PART_Track">
					<Track.DecreaseRepeatButton>
						<RepeatButton Command="Slider.DecreaseLarge"
								  Style="{StaticResource OpacitySliderRepeatButtonStyle}"/>
					</Track.DecreaseRepeatButton>

					<Track.IncreaseRepeatButton>
						<RepeatButton Command="Slider.IncreaseLarge"
								  Style="{StaticResource OpacitySliderRepeatButtonStyle}"/>
					</Track.IncreaseRepeatButton>

					<Track.Thumb>
						<Thumb Style="{StaticResource verticalThumb}"/>
					</Track.Thumb>
				</Track>
			</Grid>
		</Border>

		<ControlTemplate.Triggers>
			<Trigger Property="Height" Value="Auto">
				<Setter Property="MinHeight" Value="104"/>
			</Trigger>
			<Trigger Property="Width" Value="Auto">
				<Setter Property="MinWidth" Value="21"/>
			</Trigger>
			<Trigger Property="IsDirectionReversed" Value="True">
				<Setter TargetName="opacityGradientHost" Property="Background">
					<Setter.Value>
						<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
							<GradientStop Offset="0.0" Color="Black" />
							<GradientStop Offset="1.0" Color="Transparent" />
						</LinearGradientBrush>
					</Setter.Value>
				</Setter>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>

	<!-- Slider Style -->
	<Style TargetType="{x:Type local:OpacitySlider}">
		<Setter Property="IsMoveToPointEnabled" Value="True"/>
		<Setter Property="Template" Value="{StaticResource horizontalSlider}"/>
		<Style.Triggers>
			<Trigger Property="Orientation" Value="Vertical">
				<Setter Property="Template" Value="{StaticResource verticalSlider}"/>
			</Trigger>
		</Style.Triggers>
	</Style>
</ResourceDictionary>